package com.aids_malaria.http.response;

/**
 * Author: fwp
 * Date: 2019-04-09
 * Description: 后台返回的数据格式 ,到时候根据实际情况作修改
 */

public class BaseResponse<T> {

    private String code;
    private String message;
    private T data;
    private String datasize;
    private static final String CODE_SUCCESS = "100";//成功的code
    private static final String CODE_OVER_TOKEN_ONE = "300";//token过期的code
    private static final String CODE_OVER_TOKEN_TWO = "400";//token过期的code

    /**
     * 是否请求数据成功
     * @return
     */
    public boolean isSuccess(){
        return CODE_SUCCESS.equals(getCode());
    }

    /**
     * 是否token过期
     * @return
     */
    public boolean isOverToken(){
        return CODE_OVER_TOKEN_ONE.equals(getCode()) || CODE_OVER_TOKEN_TWO.equals(getCode());
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public String getDatasize() {
        return datasize;
    }

    public void setDatasize(String datasize) {
        this.datasize = datasize;
    }

    @Override
    public String toString() {
        return "BaseResponse{" +
                "code=" + code +
                ", message='" + message + '\'' +
                ", data=" + data +
                '}';
    }
}
